<template>
  <div>
    <Goods
      :list="list"
      :start="start"
      :limit="limit"
      :total="total"
      :brand-list="brandList"
      @search="search"
      @handle-size-change="handleSizeChange"
      @handle-current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
import {
  productsByPage,
  findAllBrand
} from '@/api/goodsManage/goodsList/index.js'
import mix from '@/mixins/index.js'
import Goods from '@/components/Goods/index'
export default {
  components: {
    Goods
  },
  mixins: [mix],
  data() {
    return {
      list: [],
      brandList: [],
      formData: {
        'brandId': '',
        'id': '',
        'name': '',
        'productCategoryId': '',
        'productSn': '',
        'publishStatus': '',
        'verifyStatus': ''
      }
    }
  },
  computed: {

  },
  created() {
    this.init()
    findAllBrand()
      .then(res => {
        this.brandList = res.data.items
      })
  },
  mounted() {

  },
  methods: {

    search(val) {
      console.log('子组件传递的数据', val)
      this.formData = val
      this.init()
    },
    addGoods() {
      this.$router.push({ name: 'goodsManageAddGoods' })
    },
    onSubmit() {
      this.init()
    },
    init() {
      productsByPage(this.start, this.limit, this.formData)
        .then(res => {
          console.log(res)
          this.list = res.data.rows
          this.total = res.data.total
        })
    }
  }
}
</script>

<style scoped lang="scss">

</style>
